/*
 * @Author: JPeng 872639397@qq.com
 * @Date: 2022-05-11 10:56:34
 * @LastEditors: JPeng 872639397@qq.com
 * @LastEditTime: 2022-05-13 11:02:15
 * @FilePath: \算法测试\复习！！！\Promise\02.file.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
const fs = require('fs');

// fs.readFile('./复习！！！/Promise/text/01.txt', (err, data) => {
//     if (err) throw err;
//     console.log(data);
// })

const p = new Promise((resolve, rejected) => {
    fs.readFile('./text/01.txt', (err, data) => {
        if (err) rejected(err);
        console.log(1);
        resolve(data);
        console.log(2);
    })
})


let result = p.then((value) => {
    console.log("我先");
    console.log(value.toString());
},(err)=>{
    console.log(err);
})

console.log(result);

p.catch(err => {
    console.log(123);
    console.log(err);
})